package com.example.demo.Demo1;

import com.example.demo.Character.Talker;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

@RequestMapping("/message")
@RestController
public class TalkController {
    private List<Talker> list = new ArrayList<>();
    @RequestMapping("/talk")
    public Boolean fun1(Talker talker){
    if(!StringUtils.hasLength(talker.getFrom())||!StringUtils.hasLength(talker.getTo())||!StringUtils.hasLength(talker.getMessage())){
        return false;
    }
    list.add(talker);
    return true;
    }

    @RequestMapping("/getMessage")
    public List<Talker> fun2(){
        return list;
    }
    @RequestMapping("/test01")
    public String fun4(){
        return "adaa";
    }
}
